package com.tinxing.bp.commons.utils.exception;


import com.tinxing.bp.commons.utils.util.VerifyParams;

/**
 * @description 封装自定义的异常
 * @author yangxianghua  2020年10月28日 下午17:09:48 周三
 */
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = -8490759249013729324L;

    private Integer code;

    public ServiceException(ServiceExceptionEnum serviceExceptionEnum) {
        this.code = serviceExceptionEnum.getCode();
        this.message = serviceExceptionEnum.getMessage();
    }

    private String message;

    public ServiceException(String message) {
        this.code = 500;
        this.message = message;
    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(String message, Object... objects) {
        this.message = VerifyParams.formats(message, objects);
        this.code = 500;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
